package com.google.coffeeshop.gui.desktop.product;

import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import com.google.coffeeshop.business.ManagerBusiness;
import com.google.coffeeshop.entity.EmployeeDTO;
import com.google.coffeeshop.gui.desktop.AbstractBasePanel;
import com.google.coffeeshop.gui.desktop.employee.AddEditEmployeeFrame;
import com.google.coffeeshop.gui.desktop.employee.EmployeeActionsPanel;
import com.google.coffeeshop.gui.desktop.employee.EmployeePanel;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;

public class ProductActionPanel  extends AbstractBasePanel{
	
	private ProductPanel productPanel;
	
	public ProductActionPanel(final ProductPanel panel) {
		this.productPanel = panel;
		JToolBar toolbar = new JToolBar();
		
		JButton btnAdd = new JButton("Add");
		btnAdd.setVerticalTextPosition(SwingConstants.BOTTOM);
		btnAdd.setHorizontalTextPosition(SwingConstants.CENTER);
		btnAdd.setIcon(new ImageIcon(EmployeeActionsPanel.class.getResource("/com/google/coffeeshop/gui/desktop/icon/size24/add-24.png")));
		btnAdd.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				ProductForm frmProduct = new ProductForm(productPanel);
				frmProduct.setVisible(Boolean.TRUE);
			}
		});
		setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));
		toolbar.add(btnAdd);
		
		JButton btnEdit = new JButton("Edit");
		btnEdit.setVerticalTextPosition(SwingConstants.BOTTOM);
		btnEdit.setHorizontalTextPosition(SwingConstants.CENTER);
		btnEdit.setIcon(new ImageIcon(EmployeeActionsPanel.class.getResource("/com/google/coffeeshop/gui/desktop/icon/size24/edit-24.png")));
		btnEdit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				productPanel.showProductForm();
			}
		});
		
		toolbar.add(btnEdit);
		
		JButton btnProductFroup = new JButton("Product Group");
		btnProductFroup.setVerticalTextPosition(SwingConstants.BOTTOM);
		btnProductFroup.setHorizontalTextPosition(SwingConstants.CENTER);
		btnProductFroup.setIcon(new ImageIcon(EmployeeActionsPanel.class.getResource("/com/google/coffeeshop/gui/desktop/icon/size24/cate.png")));
		btnProductFroup.addMouseListener(new MouseAdapter() {
		@Override
			public void mouseClicked(MouseEvent arg0) {
			ProductGroupFrame productGroupFrame = new ProductGroupFrame();
			productGroupFrame.setVisible(Boolean.TRUE);
			}
		});
		toolbar.add(btnProductFroup);
		
		add(toolbar);
	}

	private static final long serialVersionUID = 1L;
	
}
